<?php $this->load->view('common/head');?>
<div class="tabbable tabs-left" id="myTabs">
	<ul class="nav nav-tabs">
		<?php foreach ($actItemType as $k => $v) {?>
		<li>
			<a href="#panel-<?=$k?>" data-toggle="tab"><?=$v?></a>
		</li>
		<?php } ?>
	</ul>
	<div class="tab-content">
		<?php foreach ($actItemType as $k => $v) {?>
		<div class="tab-pane active" style="padding-top: 1px;" id="panel-<?=$k?>">
			<?php $this->load->view('AdminProAct/itemForm'.$k); ?>
		</div>
		<?php } ?>
	</div>
</div>
<script type="text/javascript">
$(function(){
	$('#myTabs a[href="#panel-<?=$itemData['type']?$itemData['type']:1?>"]').tab('show');
	initValidation();
	$.each( defaultValues, function(i, n){
		addInput('table3',i);
		addInput('table4',i);
	});
	$("body").on('click',".delInput",function(e){
		$(this).parent().parent().remove();
	});
	//时间限制调整
	$("input[name='limit[type]']").change(function(){
		if($(this).val()==1){
			$("#timeInputBox").show();
			$("input[name='limit[startTime]'],input[name='limit[endTime]']").attr('required',true);
		}else{
			$("#timeInputBox").hide();
			$("input[name='limit[startTime]'],input[name='limit[endTime]']").attr('required',false);
		}
	});
});
//初始化验证
function initValidation(){
	$('form[name="add"]').find("input,select,textarea").jqBootstrapValidation("destroy");
	$('form[name="add"]').find("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
	    preventSubmit:false,
	    submitSuccess: function (form, event) {
	         event.preventDefault();
	         ajaxFormSubmit(form.attr('id'));
	     },
	     submitError: function (form, event, errors) {
	       event.preventDefault();
	       }
  	});
}
//字母列表
var zimu = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N'];
<?php $defaultValues = isset($itemData['otherData']['options']) ? $itemData['otherData']['options'] : array('','') ?>
var defaultValues = <?=jsonEncode($defaultValues)?>;
function addInput(tableId,i){
	//表格行数
	var tableTrNum = $('#'+tableId+' tr').length;
	var index = arguments[1] ? arguments[1] : tableTrNum;
	//默认值
	var value = '';
	if (defaultValues[index] != undefined) {
		var value = defaultValues[index];
	}
	if( tableTrNum < zimu.length){
		var html = '<tr align="left"><td class="text-right">选择'+zimu[index]+':</td><td><input type="text" required class="form-control" name="options[]" id="option'+index+'" style="width: 200px;" value="' +value+ '"></td><td>';
		if (tableTrNum > 1) {
			html += '<a role="button" class="btn btn-default btn-info delInput">删除选项</a>';
		}
		html +='</td></tr>';
		$('#'+tableId).append(html);
	}else{
		alert('最多允许添加'+ zimu.length + '个选项');
		return false;
	}
}
</script>
<?php $this->load->view('common/foot');?>